﻿using Autofac;
using NewsSevicer.Interface;
using NewsSevicer;
using NewsEntity.Models;
namespace NetDiskStorageWebApi.Configuration
{
    public static class AutofacConfig
    {
        public static Autofac.IContainer ConfigureContainer()
        {
            var builder = new ContainerBuilder();
            // 注册服务
            builder.RegisterType<OnlineUserService>().As<IOnlineUserService>().InstancePerLifetimeScope();
            
            builder.RegisterType<AdminServer>().As<IAdminServer>().InstancePerLifetimeScope();
            builder.RegisterType<NewsServer>().As<INews>().InstancePerLifetimeScope();
            builder.RegisterType<NewsEntity.Models.NewsContext>().InstancePerLifetimeScope();
            
            
            
            builder.RegisterType<TestServier>().As<ITest>().InstancePerLifetimeScope();
            builder.RegisterType<WebSocketServer>().SingleInstance(); // 使用 Autofac 注册单例服务

            // 构建容器
            return builder.Build();
        }
    }

}
